package com.matt.controller;

import com.matt.commons.dto.sso.StaffDTO;
import com.matt.commons.model.StatusResponse;
import com.matt.domain.AreaLogo;
import com.matt.foundation.model.MemVerificationCache;
import com.matt.foundation.query.ChildrenActiveQuery;
import com.matt.foundation.vo.ChildActivityVo;
import com.matt.service.AreaLogoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import static com.matt.foundation.constant.RequestConstant.TICKET;

@RestController
@RequestMapping("areaLogo")
public class AreaLogoController {

    @Autowired
    private AreaLogoService areaLogoService;
    @Autowired
    private MemVerificationCache cache;

    @ApiOperation(value = "新增或者编辑logo", httpMethod = "POST", hidden = false)
    @PostMapping("/addOrUpdate")
    public StatusResponse addOrUpdate(@RequestHeader(TICKET) String ticket,
                                      String name,
                                      Integer type,
                                      String logUrl,
                                      String id
    ) {
        StaffDTO baseInfo = cache.getStaff(ticket);
        return StatusResponse.success(
                areaLogoService.addOrUpdate(name,type,baseInfo,id,logUrl)
        );
    }
    @ApiOperation(value = "logo列表",httpMethod = "POST")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public StatusResponse page(@RequestHeader(TICKET) String ticket, ChildrenActiveQuery query) {
        Page<AreaLogo> page = areaLogoService.page(query);
        return StatusResponse.success(page);
    }

    @ApiOperation(value = "logo删除",httpMethod = "POST")
    @RequestMapping(value = "/delete")
    public StatusResponse delete(@RequestHeader(TICKET) String ticket,String id) {
        String areaId = cache.getAreaId(ticket);
        return StatusResponse.success(areaLogoService.delete(id));
    }

}
